#include <bits/stdc++.h>
using namespace std;
const double eps=1e-9;
struct data{
	long long p,v,a;
}d[100005];
struct range{
	long long l,r;
	bool operator<(const range &t)const{
		if(l!=t.l)
			return l<t.l;
		return r<t.r;
	}
}r[100005],prer[100005];
struct st{
	struct stree{
		int l,r,val;
	}t[400005];
	void pushup(int idx){
		t[idx].val=min(t[2*idx].val,t[2*idx+1].val);
	}
	void build(int idx,int l,int r){
		t[idx].l=l,t[idx].r=r;
		if(l==r){
			t[idx].val=0;
			return;
		}
		int mid=l+r>>1;
		build(2*idx,l,mid);
		build(2*idx+1,mid+1,r);
		pushup(idx);
	}
	void update(int idx,int pos,int val){
		if(t[idx].l==t[idx].r){
			t[idx].val=val;
			return;
		}
		int mid=t[idx].l+t[idx].r>>1;
		if(pos<=mid)
			update(2*idx,pos,val);
		else
			update(2*idx+1,pos,val);
		pushup(idx);
	}
	int query(int idx,int l,int r){
		if(l>r)
			return 0;
		if(l<=t[idx].l&&t[idx].r<=r)
			return t[idx].val;
		int mid=t[idx].l+t[idx].r>>1;
		int res=1e9;
		if(l<=mid)
			res=min(res,query(2*idx,l,r));
		if(mid+1<=r)
			res=min(res,query(2*idx+1,l,r));
		return res;
	}
}segt;
long long T,n,m,L,V,cnt;
long long p[100005],pre[100005],dp[100005];
void clear(){
	for(int i=1;i<=max(n,m);i++){
		p[i]=0;
		pre[i]=0;
		dp[i]=0;
		d[i]={0,0,0};
		r[i]={0,0};
		prer[i]={0,0};
	}
}
void solve(){
	cin>>n>>m>>L>>V;
	for(int i=1;i<=n;i++){
		cin>>d[i].p>>d[i].v>>d[i].a;
	}
	for(int i=1;i<=m;i++){
		cin>>p[i];
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		int pos=lower_bound(p+1,p+m+1,d[i].p)-p;
		if(pos>m)
			continue;
		if(!d[i].a){
			if(d[i].v>V){
				ans++;
				r[i]={pos,m};
			}
			continue;
		}
		if(d[i].a>0){
			if(d[i].v>V){
				ans++;
				r[i]={pos,m};
				continue;
			}
			double t=1.0*(V-d[i].v)/(1.0*d[i].a);
			double s=1.0*d[i].v*t+0.5*d[i].a*t*t;
			long long np;
			if(fabs(s-((round(s))))<eps)
				np=d[i].p+(long long)s;
			else
				np=d[i].p+ceil(s);
			int rpos=upper_bound(p+1,p+m+1,np)-p;
			if(rpos<=m){
				ans++;
				r[i]={rpos,m};
			}
		}
		else{
			//cout<<"querying:"<<d[i].p<<" "<<d[i].v<<" "<<d[i].a<<endl;
			if(d[i].v<=V)
				continue;
			double t=1.0*(d[i].v-V)/(-1.0*d[i].a);
			double s=1.0*V*t-0.5*d[i].a*t*t;
			long long np;
			if(fabs(s-((long long)s))<eps)
				np=d[i].p+(long long)(s-1);
			else
				np=d[i].p+floor(s);
			int rpos=upper_bound(p+1,p+m+1,np)-p-1;
			if(pos<=rpos){
				ans++;
				r[i]={pos,rpos};
			}
		}
	}
	//cout<<"bef sort"<<endl;
	/*
	for(int i=1;i<=n;i++){
		cout<<r[i].l<<" "<<r[i].r<<endl;
	}
	cout<<endl<<endl;
	*/

	sort(r+1,r+n+1);
	/*
	for(int i=1;i<=n;i++){
		cout<<r[i].l<<" "<<r[i].r<<endl;
	}
	*/
	int st=1;
	while(!r[st].r&&st<=n){
		st++;
	}
	if(st>n){
		cout<<0<<" "<<m<<"\n";
		clear();
		return;
	}
	//big range is useless
	int cnt=1;
	//cout<<"st="<<st<<endl;
	ans=n-st+1;
	r[1]=r[st];
	for(int i=st+1;i<=n;i++){
		//cout<<"cur r="<<r[i].l<<" "<<r[i].r<<endl;
		if(r[i].l==r[cnt].l&&r[i].r>=r[cnt].r)
			continue;
		r[++cnt]=r[i];
	}
	/*
	cout<<endl;
	cout<<"after range:"<<endl;
	for(int i=1;i<=cnt;i++){
		cout<<r[i].l<<" "<<r[i].r<<endl;
	}
	cout<<endl<<endl;
	*/
	int lcnt=0;
	long long minr=r[cnt].r;
	prer[++lcnt]=r[cnt];
	for(int i=cnt-1;i>=1;i--){
		if(r[i].r>=minr)
			continue;
		prer[++lcnt]=r[i];
		minr=min(minr,r[i].r);
	}
	for(int i=1;i<=lcnt;i++){
		r[i]=prer[lcnt-i+1];
	}
	cnt=lcnt;
	/*
	cout<<endl;
	cout<<"after range:"<<endl;
	for(int i=1;i<=cnt;i++){
		cout<<r[i].l<<" "<<r[i].r<<endl;
	}
	cout<<endl<<endl;
	*/
	//query pre
	pre[1]=0;
	int bpos=0,precur=1;
	for(int i=2;i<=cnt;i++){
		if(r[i].l<=r[1].r)
			pre[i]=0;
		else{
			bpos=i;
			break;
		}
	}
	for(int i=bpos;i<=cnt;i++){
		while(r[precur+1].r<r[i].l&&precur<cnt){
			precur++;
		}
		pre[i]=precur;
	}
	/*
	cout<<endl;
	cout<<"pre:"<<endl;
	for(int i=1;i<=cnt;i++){
		cout<<pre[i]<<" ";
	}
	cout<<endl<<endl;
	*/
	segt.build(1,1,cnt);
	for(int i=1;i<=cnt;i++){
		if(!pre[i])
			dp[i]=1;
		else
			dp[i]=segt.query(1,pre[i],i-1)+1;
		segt.update(1,i,dp[i]);
	}
	cout<<ans<<" "<<m-dp[cnt]<<"\n";
	//cout<<endl<<endl;
	clear();
}
signed main(){
	std::ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	cin>>T;
	//T=1;
	clear();
	while(T--){
		//clear();
		solve();
	}
	return 0;
}